const app = getApp();
Component({
  /**
   * 组件的一些选项
   */
  options: {
    addGlobalClass: true,
    multipleSlots: true
  },
  /**
   * 组件的对外属性
   */
  properties: {
    bgColor: {
      type: String,
      value: 'mbg'
    }, 
    isCustom: {
      type: [Boolean, String],
      default: false
    },
    isBack: {
      type: [Boolean, String],
      default: false
    },
    bgImage: {
      type: String,
      default: ''
    },
    name: {
      type: String,
      default: ''
    },
    backImage: {
      type: String,
      value: '/images/back.png'
    },
    textColor: {
      type: String,
      value: '#000'
    },
    isCenter: {
      type: [Boolean, String],
      default: false
    },
  },
  lifetimes: {
    attached: function() {
      // 在组件实例进入页面节点树时执行
      if(this.data.isCenter == 'true'){
        this.setData({
          centerName:this.data.name
        })
      }else if(app.globalData.platform == "devtools"){
        this.setData({
          centerName:this.data.name
        })
      }else if(app.globalData.platform == "ios"){
        this.setData({
          centerName:this.data.name
        })
      }else if(app.globalData.platform == "android"){
        this.setData({
          leftName:this.data.name
        })
      }
    },
    detached: function() {
      // 在组件实例被从页面节点树移除时执行
    },
  },
  /**
   * 组件的初始数据
   */
  data: {
    StatusBar: app.globalData.StatusBar,
    CustomBar: app.globalData.CustomBar,
    Custom: app.globalData.Custom,
    leftName:"",
    centerName:""
  },
  /**
   * 组件的方法列表
   */
  methods: {
    BackPage() {
      var myEvent = { // detail对象，提供给事件监听函数
        isBack:this.data.isBack
      }
      if(this.data.isBack){
        wx.navigateBack({
          delta: 1,
          fail:function(err){
          }
        });
        this.triggerEvent('myevent', myEvent) 
      }else{
        this.triggerEvent('myevent', myEvent)  
      }
     
    },
    toHome(){
      wx.reLaunch({
        url: '/pages/index/index',
      })
    }
  },

})